package docoffice.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListSelectionModel;

import docoffice.doss.Appointment;

public class ViewAppt extends JPanel {
	
	private JLabel title;
	
	private JList list;
	DefaultListModel model;
	
	public ViewAppt() {
		title = new JLabel("View Requested Appointments");
		
		list = new JList();
		
		model = new DefaultListModel();
		list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
		//list.setVisibleRowCount(-1);
		
		Appointment a = new Appointment("", "", "", null);
		ArrayList<String> appointments = a.readAllAppointments();
		
		for (int i = 0; i < appointments.size(); i++){
			model.addElement(appointments.get(i));
			System.out.println(appointments.get(i));
		}
		
		setLayout(new GridLayout(3, 1, 15, 10));
		add(title);
		add(list);
		
		setPreferredSize(new Dimension(400, 125));
		setBackground(Color.WHITE);
	}

}
